<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>报修申请</title>
<link href="static/css/style.css" rel="stylesheet" type="text/css" />
<link href="static/css/select.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="static/js/jquery.js"></script>
<script type="text/javascript" src="static/js/jquery.idTabs.min.js"></script>
<script type="text/javascript" src="static/js/select-ui.min.js"></script>
<script type="text/javascript" src="static/editor/kindeditor.js"></script>

<script type="text/javascript">
    KE.show({
        id : 'content7',
        cssPath : './index.css'
    });
</script> 
<script type="text/javascript">
$(document).ready(function(e) {
    $(".select1").uedSelect({
		width : 345			  
	});
	$(".select2").uedSelect({
		width : 167  
	});
	$(".select3").uedSelect({
		width : 100
	});
});
</script>
<script type="text/javascript">  
//页面加载时首先获得部门
    $(function(){  
        $.ajax({  
            type:"post",  
            url:"department",  
            dataType:"json",  
            async:false,  
            success:function(data){  
                var dept=eval("("+data+")");
                for(var i=0;i<dept.length;i++){  
                    $("#department").append("<option value="+dept[i].id+">"+dept[i].deptName+"</option>");  
                }  
            }  
        });  
    });  
  
</script> 

<script type="text/javascript">
$(function(){   
	$('#createApply').click(function() {
			var department = $('#deptId').val();
			var laboratory = $('#labId').val();
			var equipment = $('#equipId').val();
			if (department == '') {
				alert('请选择部门！');
				return false;
			} 
			if (laboratory == '') {
				alert('请选择实验室！');
				return false;
			} 
			if (equipment == '') {
				alert('请选择设备！');
				return false;
			} 
			$('#addApply').submit();
		});
	});
</script>

</head>

<body>

	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="PageFrame_index.action">首页</a></li>
    </ul>
    </div>
    
    <div class="formbody">
    
    
    <div id="usual1" class="usual"> 
    
    <div class="itab">
  	<ul> 
    <li><a href="#tab1" class="selected">报修申请</a></li> 
  	</ul>
    </div> 
    
    <form name="addApply" action="RepairApplication_doSave" method="post">
  	<div id="tab1" class="tabson">
    
    <div class="formtext">Hi，<b>${user.userName}</b>，欢迎您试用报修申请功能！</div>
    <!-- 三级联动参考   http://blog.csdn.net/luckey_zh/article/details/22995389 -->
    <ul class="forminfo">
     <li><label>部门<b>*</b></label>
 	   <div class="vocation">
    	<!-- 如果使用 select1 可能导致取不到值-->
    	<select id="department" name="department" class="select2">
		<option value="0">--请选择--</option>  
	    </select>
	  </div>
 	</li>
 	<li><input type="hidden" id="deptId" name="deptId" value=""/>  </li>      
 	 	<li><label>实验室<b>*</b></label>
 	   <div class="vocation">
    	<!-- 如果使用 select1 可能导致取不到值-->
    	<select id="laboratory" name="laboratory" class="select2">
            <option>--请选择--</option>  
	    </select>
	  </div> 
 	</li>
 	<li><input type="hidden" id="labId" name="labId" value=""/>  </li>    
 	<li><label>设备编号<b>*</b></label>
 	   <div class="vocation">
    	<!-- 如果使用 select1 可能导致取不到值-->
    	<select id="equipment" name="equipment" class="select2">
            <option>--请选择--</option>
	    </select>
	  </div> 
 	</li>
 	<li><input type="hidden" id="equipId" name="equipId" value=""/>  </li>    
 	<li><input type="hidden" id="" name="repairApplication.status" type="text" class="dfinput" value="未检测"  /></li>
 	<li><label>故障现象说明<b>*</b></label>
    <textarea id="content7" name="repairApplication.desc" style="width:700px;height:250px;visibility:hidden;"></textarea>  
    </li>
		
    <li><label>&nbsp;</label><input id="createApply" name="" type="submit" class="btn" value="马上申请"/></li>
    </ul>
    
    </div> 
    </form>
    
	</div> 
 
	<script type="text/javascript"> 
      $("#usual1 ul").idTabs(); 
    </script>
    
    <script type="text/javascript">
	$('.tablelist tbody tr:odd').addClass('odd');
	</script>
	
	<script type="text/javascript">  
  // 部门下拉列表框发生改变时候的事件 
    $("#department").change(function(){  
        var deptId = $("#department").val();
        $("#deptId").attr("value", deptId);	// 设置部门ID给隐藏框
        //如果选择的是‘==请选择==’，不会执行去查找实验室，平且把已有的数据清空  
        $(".uew-select-text").text("--请选择--");
            $("#laboratory option").remove();  
            $("#laboratory").append("<option value=0 selected='selected'>--请选择--</option>");  
            $("#equipment option").remove();  
            $("#equipment").append("<option value=0 selected='selected'>--请选择--</option>"); 
        if($("#department").val()==0){  
            return;  
        }  
        $.ajax({  
            type:"post",  
            //传一个部门的id参数  
            url:"laboratory?deptId="+deptId,  
            dataType:"json",  
            async:false,  
            success:function(laboratory){  
                var lab = eval("("+laboratory+")");  
                for(var i=0;i<lab.length;i++){  
                    $("#laboratory").append("<option value="+lab[i].id+">"+lab[i].labName+"</option>");  
                }  
            }  
        });  
    });  
    //实验室下拉列表框发生改变时候的事件  
    $("#laboratory").change(function(){  
        var labId = $("#laboratory").val();
        $("#labId").attr("value", labId);	// 设置实验室ID给隐藏框
        $(".uew-select-text").eq(2).text("--请选择--");
        $("#equipment option").remove();  
        $("#equipment").append("<option value=0>--请选择--</option>");  
        if($("#laboratory").val()==0){  
            return;  
        }   
        $.ajax({  
            type:"post",  
            url:"equipment?labId="+labId,  
            dataType:"json",  
            async:false,  
            success:function(equipment){  
                var equip = eval("("+equipment+")");  
                for(var i=0;i<equip.length;i++){  
                    $("#equipment").append("<option value="+equip[i].id+">"+equip[i].equipName+"</option>");  
                }  
            }  
        });  
    });  
    
	$("#equipment").change(function(){
		$("#equipId").attr("value", $("#equipment").val());
	});
  </script>  
	

	</div>


</body>

</html>
